home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / gamesa / frmshuff.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-08-01  |  3.2 KB  |  146 lines

  1. VERSION 5.00
  2. Begin VB.Form frmShuffle 
  3.    AutoRedraw      =   -1  'True
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Puzzle"
  6.    ClientHeight    =   5625
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   4905
  10.    BeginProperty Font 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   9.75
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    Icon            =   "frmShuffle.frx":0000
  20.    KeyPreview      =   -1  'True
  21.    LinkTopic       =   "Form1"
  22.    MaxButton       =   0   'False
  23.    MinButton       =   0   'False
  24.    ScaleHeight     =   300
  25.    ScaleMode       =   0  'User
  26.    ScaleWidth      =   250
  27.    ShowInTaskbar   =   0   'False
  28.    StartUpPosition =   2  'CenterScreen
  29. Attribute VB_Name = "frmShuffle"
  30. Attribute VB_GlobalNameSpace = False
  31. Attribute VB_Creatable = False
  32. Attribute VB_PredeclaredId = True
  33. Attribute VB_Exposed = False
  34. Option Explicit
  35. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  36. If KeyCode = 40 Or KeyCode = 98 Then
  37. If r <> 1 Then
  38. t = num(r, c)
  39. num(r, c) = num(r - 1, c)
  40. num(r - 1, c) = t
  41. r = r - 1
  42. nom = nom + 1
  43. Form_Load
  44. End If
  45. End If
  46. If KeyCode = 38 Or KeyCode = 104 Then
  47. If r <> 4 Then
  48. t = num(r, c)
  49. num(r, c) = num(r + 1, c)
  50. num(r + 1, c) = t
  51. r = r + 1
  52. nom = nom + 1
  53. Form_Load
  54. End If
  55. End If
  56. If KeyCode = 37 Or KeyCode = 100 Then
  57. If c <> 4 Then
  58. t = num(r, c)
  59. num(r, c) = num(r, c + 1)
  60. num(r, c + 1) = t
  61. c = c + 1
  62. nom = nom + 1
  63. Form_Load
  64. End If
  65. End If
  66. If KeyCode = 39 Or KeyCode = 102 Then
  67. If c <> 1 Then
  68. t = num(r, c)
  69. num(r, c) = num(r, c - 1)
  70. num(r, c - 1) = t
  71. c = c - 1
  72. nom = nom + 1
  73. Form_Load
  74. End If
  75. End If
  76. If KeyCode = 27 Then
  77. MsgBox "Better luck next time !!! Goodbye!!!", vbOKOnly
  78. Unload frmShuffle
  79. frmMain.Show 1
  80. End If
  81. check
  82. If flag = 1 Then
  83. MsgBox "Congrats !!! You have done it !!!" + vbCrLf + "Number of moves : " + Str(nom)
  84. Unload frmShuffle
  85. frmMain.Show 1
  86. End If
  87. End Sub
  88. Private Sub Form_Load()
  89. drawcells
  90. display
  91. End Sub
  92. Public Sub display()
  93. Dim i As Integer
  94. Dim j As Integer
  95. Dim row As Integer
  96. Dim col As Integer
  97. row = 75
  98. col = 50
  99. ForeColor = RGB(0, 0, 255)
  100. For i = 1 To 4
  101. For j = 1 To 4
  102. PSet (col, row), BackColor
  103. If num(i, j) = 0 Then
  104. Print " "
  105. Print num(i, j)
  106. End If
  107. col = col + 50
  108. If col > 225 Then
  109. col = 50
  110. row = row + 50
  111. End If
  112. Next j
  113. Next i
  114. End Sub
  115. Public Sub drawcells()
  116. frmShuffle.Cls
  117. PSet (40, 10), BackColor
  118. ForeColor = RGB(0, 0, 0)
  119. Print "Use arrow keys to move numbers"
  120. PSet (80, 25), BackColor
  121. Print "Press Esc to quit"
  122. ForeColor = RGB(255, 255, 0)
  123. DrawWidth = 3
  124. Line (25, 50)-(225, 250), , B
  125. Line (75, 100)-(225, 250), , B
  126. Line (125, 150)-(225, 250), , B
  127. Line (175, 200)-(225, 250), , B
  128. Line (25, 50)-(175, 200), , B
  129. Line (25, 50)-(125, 150), , B
  130. Line (25, 50)-(75, 100), , B
  131. PSet (75, 275), BackColor
  132. ForeColor = RGB(0, 0, 0)
  133. Print "Number of moves : " + Str(nom)
  134. End Sub
  135. Public Sub check()
  136. Dim i As Integer
  137. Dim j As Integer
  138. For i = 1 To 4
  139. For j = 1 To 4
  140. If num(i, j) <> rum(i, j) Then GoTo subr
  141. Next j
  142. Next i
  143. flag = 1
  144. subr:
  145. End Sub
  146.